Hey guys, I need some help. Does anyone have any clue what the linker error
undefined reference to `___ashrsi3'
refers to? It seems like it involves the math library libm.a, but linking with -lm doesn't help, nor does #include <math.h>
Hey guys, I need some help. Does anyone have any clue what the linker error
undefined reference to `___ashrsi3'
refers to? It seems like it involves the math library libm.a, but linking with -lm doesn't help, nor does #include <math.h>
You probably forgot to define a function named ashrsi3 (or something like that).
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Where's the source code?
Is it something you wrote (post it), or some random thing you downloaded off the web (URL).
Note however, that we're not a "please fix this code I found on the web" site.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Source code:
It's for a SEGA Saturn. I was just curious if anyone could point me in the right direction as how to go about solving this. I'm not looking for someone to do this for me. I've been trying to find a clue to this literally all day, and I'm only asking for help because I'm out of ideas. I just thought someone else might've worked on something and had the same error, meaning this might be a common issue, not just related to the Saturn libraries.Code:#include <sgl.h> #include "main.h" #include <sega_sys.h> #define NoSprites 2 extern PICTURE pic_spr[]; void load_sprite(PICTURE *pcptr, Uint32 NbPicture) { TEXTURE *txptr ; for(; NbPicture-- > 0 ; pcptr++){ txptr = tex_spr + pcptr->texno ; slDMACopy(pcptr->pcsrc, (void *)(SpriteVRAM + ((txptr->CGadr) << 3)), (txptr->Hsize * txptr->Vsize * 4) >> (pcptr->cmode)) ; } } FIXED tpos[] = {toFIXED(0), toFIXED(0), toFIXED(0), toFIXED(0)}; SPR_ATTR tattr[] = { SPR_ATTRIBUTE(0, No_Palet, No_Gouraud, CL32KRGB, sprNoflip) }; void ss_main(void) { ANGLE ang = DEGtoANG(0.0); slInitSystem(TV_320x240, tex_spr, 1); load_sprite(pic_spr, NoSprites); slColRAMMode(CRM16_1024); slBack1ColSet((void*)BACK_COL_ADR, (Uint16)0); while(1) { slDispSprite(tpos, tattr, ang); slPrint("WTF? YO?", slLocate(1, 1)); slSynch(); } }
I took part of this code from a similar program that gets the exact same errors when I try to compile that one. The error seems to come from the load_sprite function, because when I comment it out, the error goes away. The code is necessary to show the sprite on-screen, though. The program I took this from had been compiled by someone else and worked, and another tutorial file backs the code up, so I'm confident it isn't the source code, it's how it's being compiled. I was kinda wondering if maybe ashrsi was present in an old version of libm.a, and has been removed.
The function isn't in the source code. The compiler says there's a linker error. I looked this error up, and I found a site (in Japanese ) that seems to have solved the issue, and all I could really gather was to link with libm.a with -lm.You probably forgot to define a function named ashrsi3 (or something like that).
Last edited by aeroflotte; 11-24-2014 at 02:33 AM.
You probably read a thread where someone had problems trying to use a function declared in <math.h> when compiling with a compiler that did not automatically link to the math component of the C standard library implementation. Under these circumstances -lm is the appropriate solution. In your case though, you have a similiar problem, but it is not the same: you need to find out what is the library to link to, and that usually means reading relevant documentation.Originally Posted by aeroflotte
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Thanks, you gave me a great idea and I followed it and solved my problem. The library I had that was made for Unix lacked the necessary files, so I looked at the Windows libraries and found what I needed. Compiles just fine!
I think ashrsi3.c is the exact library that contains this scalar function. But this is compiled from linux I don't know whats your deal with it.
There is a manual linker as a setting of your compiler, try it.
EDIT: Nevermind haha.
Just out-of-curiosity how a library made for Windows installed just fine on UNIX?
I think it was made for both, but the particular package for Unix that aeroflotte was missing something (a makefile of some sort, perhaps?)
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
It works on both platforms, only the one that was made to be more Unix friendly didn't have all the libraries and header files that the original had.